//
// Created by Andy on 2025/8/12.
//
#ifndef MOTORCONTROL_CAN_INTARFACE_H
#define MOTORCONTROL_CAN_INTARFACE_H

#include <QThread>
#include "HCanbus.h"

class recv_thread : public QThread {
Q_OBJECT
public:
    recv_thread();
    ~recv_thread();
    void run(void);
    void stop(void);
//    void receivecan(int st);
private:
    int breakout = 0;
    Can_Msg rmgs[500];
signals:
    void receivemsg(Can_Msg *msg,int lenth);
};

class can_intarface : public QObject {
Q_OBJECT
public:
    can_intarface();
    ~can_intarface();
    int get_port(void);
    int open_port(int idx);
    int close_port(void);
    int send_frame(int idx, uint8_t data);

private slots:
    void readcan(Can_Msg *rmgs, int lenth);

private:
    int can_port_num;
    int current_can_port;

    recv_thread *recv;
};


#endif //MOTORCONTROL_CAN_INTARFACE_H
